home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1999 #2
/
Amiga Plus CD - 1999 - No. 2.iso
/
System-Boost
/
Workbench
/
Archive
/
XPK
/
xpk_Source
/
xpkmaster
/
fib.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-11-15
|
2KB
|
75 lines
#ifndef XPKMASTER_FIB_C
#define XPKMASTER_FIB_C
/* Routinesheader
Name: fib.c
Main: xpkmaster
Versionstring: $VER: fib.c 1.3 (30.10.1998)
Author: SDI
Distribution: Freeware
Description: FIB related routines
1.0 05.10.96 : first real version
1.1 20.12.97 : code cleanup
1.2 09.01.98 : added XPK_ALLINONE
1.3 30.10.98 : added getUClen and fixed updatefib a bit
*/
#include <proto/exec.h>
#include <proto/dos.h>
#include <exec/types.h>
#include "xpkmaster.h"
XPK_ALLINONE void getUClen(struct XpkBuffer *xbuf, LONG *ulen, LONG *clen)
{
if(xbuf->xb_Headers.h_Glob.xsh_Flags & XPKSTREAMF_LONGHEADERS)
{
*ulen = xbuf->xb_Headers.h_Loc.xch_Long.xchl_ULen;
*clen = xbuf->xb_Headers.h_Loc.xch_Long.xchl_CLen;
}
else
{
*ulen = xbuf->xb_Headers.h_Loc.xch_Word.xchw_ULen;
*clen = xbuf->xb_Headers.h_Loc.xch_Word.xchw_CLen;
}
}
XPK_ALLINONE LONG updatefib(struct XpkBuffer *xbuf)
{
struct XpkStreamHeader *globhdr = &xbuf->xb_Headers.h_Glob;
struct XpkFib *fib = &xbuf->xb_Fib;
LONG ulen, clen;
getUClen(xbuf, &ulen, &clen);
fib->xf_Type = XPKTYPE_PACKED;
fib->xf_CLen = globhdr->xsh_CLen + 8;
fib->xf_ULen = globhdr->xsh_ULen;
fib->xf_NLen = ulen + XPK_MARGIN;
fib->xf_CCur = xbuf->xb_CCur;
fib->xf_UCur = xbuf->xb_UCur;
xbuf->xb_CCur += ROUNDLONG (clen) + xbuf->xb_Headers.h_LocSize;
xbuf->xb_UCur += ulen;
fib->xf_ID = globhdr->xsh_Type;
fib->xf_SubVersion = globhdr->xsh_SubVrs;
fib->xf_MasVersion = globhdr->xsh_MasVrs;
CopyMem(globhdr->xsh_Initial, fib->xf_Head, 16);
percentages(fib);
return addseek(xbuf);
}
XPK_ALLINONE void percentages (struct XpkFib *fib)
{
fib->xf_Ratio = 0;
if(fib->xf_ULen)
fib->xf_Ratio = 100 - 100 * fib->xf_CLen / fib->xf_ULen;
if(fib->xf_Ratio < 0)
fib->xf_Ratio = 0;
*(LONG *) fib->xf_Packer = fib->xf_ID;
fib->xf_Packer[4] = 0;
}
#endif /* XPKMASTER_FIB_C */